<template>
  <div>
    <div id="head">
      <br />
      <!-- <el-col :span="14">
        <el-autocomplete
          class="inline-input"
          v-model="patientName"
          :fetch-suggestions="querySearch"
          placeholder="请输入患者姓名"
          :trigger-on-focus="false"
          @select="handleSelect"
          @keyup.enter.native="handleSubmit"
        ></el-autocomplete>
      </el-col>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<el-button @click="select"
        >查询</el-button
      > -->
      <el-col :span="14">
        <el-input placeholder="请输入患者UID" v-model="patientCard"></el-input>
      </el-col>
      <el-button @click="select">查询</el-button>
    </div>
    <div id="div">
      <el-form :model="form">
        <el-col :span="3">
          &nbsp; 患者姓名：<el-input
            v-model="form.patient.patientName"
            :disabled="true"
          ></el-input>
          &nbsp; 患者性别：<el-input
            v-model="form.patient.patientCard"
            :disabled="true"
          ></el-input>
          &nbsp; 患者年龄：<el-input
            v-model="form.patient.patientAge"
            :disabled="true"
          ></el-input>
        </el-col>
        <el-col :span="3">
          &nbsp; 科室：<el-input
            v-model="form.dept.deptName"
            :disabled="true"
          ></el-input>
          &nbsp; 医生<el-input
            v-model="form.patientCard"
            :disabled="true"
          ></el-input>
          &nbsp; 床位<el-input
            v-model="form.patientCard"
            :disabled="true"
          ></el-input>
        </el-col>
        <el-col :span="4"> </el-col>
      </el-form>
    </div>
    &nbsp;&nbsp;&nbsp;&nbsp;

    <div>
      <br /><br /><br /><br /><br /><br /><br /><br />
      <el-divider></el-divider>
      <el-col :span="9">
        <el-table :data="operationData" style="width: 100%">
          <el-table-column
            prop="patient.patientName"
            label="患者姓名"
            width="180"
          >
          </el-table-column>
          <el-table-column
            prop="operation.operationName"
            label="手术名称"
            width="180"
          >
          </el-table-column>
          <el-table-column label="手术时间">
            <template slot-scope="scope">
              {{ scope.row.operationDate | dateFilter }}
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          >
          </el-pagination>
        </div>
      </el-col>
    </div>
  </div>
</template>

<script>
import {
  selectByName,
  selectAll,
  selectOne,
  getOperation,
} from "@/api/hospitalOperation/hospitalOperation.js";
export default {
  data() {
    return {
      currentPage: 1,
      total: 0,
      currentPage: 1,
      pageSize: 5,
      patientCard: "",
      state2: "",
      hospitalizeds: [],
      form: {
        patient: {},
        dept: {},
        doctor: {},
        sickroom: {},
      },
      operationData: [],
    };
  },
  filters: {
    dateFilter(val) {
      let date = new Date(val);
      return (
        date.getFullYear() +
        "/" +
        (date.getMonth() + 1) +
        "/" +
        date.getDate() +
        " " +
        date.getUTCHours() +
        ":" +
        date.getUTCMinutes()
      );
    },
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.getlist();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
      this.getlist();
    },
    getPatientOperation() {
      getOperation({
        pageNumber: this.currentPage,
        pageSize: this.pageSize,
        patientId: this.form.patient.patientId,
      }).then((r) => {
        this.operationData = r.data;
        this.total = r.data.total;
      });
    },
    select() {
      selectByName({ patientCard: this.patientCard }).then((r) => {
        this.form = r.data;
        this.getPatientOperation()
      });
    },

    handleSelect(item) {
      console.log(item);
    },
  },
  mounted() {
   
  },
};
</script>

<style>
#head {
  float: left;
}
</style>